import type { ConsultOrderListParams, ConsultOrderPage, ConsultOrderItem, DoctorPage, PartialConsult, KnowledgePage, KnowledgeParams, PageParams, FollowType, TopDep, Imag, ConsultOrderPreData, ConsultOrderPreParams } from '@/types/consult'
import { request } from '@/utils/request'
export const getKnowledgePage = (params: KnowledgeParams) => {
  // 返回的结果需要加在request后面，需要的参数就加函数后面
  return request<KnowledgePage>('/patient/home/knowledge', 'GET', params)
}
//  获取推荐关注医生 
export const getDoctorPage = (params: PageParams) => {
  return request<DoctorPage>('/home/page/doc', 'GET', params)
}
// 医生关注与取消关注
export const followOrUnfollow = (id: string, type: FollowType = 'doc') => {
  return request('/like', 'POST', { id, type })
}
// 科室
export const getAllDep = () => {
  return request<TopDep>('/dep/all')
}
// 上传图片
export const uploadImage = (file: File) => {
  const fd = new FormData()
  fd.append('file', file)
  return request<Imag>('/upload', 'POST', fd)
}
// 拉取预支付订单信息
// 拉取预支付订单信息
export const getConsultOrderPre = (params: ConsultOrderPreParams) => {
  return request<ConsultOrderPreData>('/patient/consult/order/pre', 'GET', params)

}

// 生成订单 修改问诊订单
export const createConsultOrder = (data: PartialConsult) => {
  return request<{ id: string }>('/patient/consult/order', 'POST', data)
}
// 获取支付地址  0 是微信  1 支付宝
export const getConsultOrderPayUrl = (params: {
  paymentMethod: 0 | 1
  orderId: string
  payCallback: string
}) => {
  return request<{ payUrl: string }>('/patient/consult/pay', 'POST', params)
}
// 查询订单详情信息
export const getConsultOrderDetail = (orderId: string) => {
  return request<ConsultOrderItem>('/patient/consult/order/detail', 'GET', { orderId })
}
// 根据处方id查询处方单
export const getPrescriptionPic = (id: string) => {
  return request<ConsultOrderItem>(`/patient/consult/prescription/${id}`)
}
// 评价问诊
export const evaluateConsultOrder = (data: {
  docId: string
  orderId: string
  score: number
  content: string
  anonymousFlag: 0 | 1
}) => {
  return request<{ id: string }>('/patient/order/evaluate', 'POST', data)
}

export const getConsultOrderList = (params: ConsultOrderListParams) => {
  return request<ConsultOrderPage>('/patient/consult/order/list', 'GET', params)
}
// 取消订单
export const cancelOrder = (id: string) => {
  return request(`/patient/order/cancel/${id}`, 'PUT')
}
// 删除订单
// 删除订单
export const deleteOrder = (id: string) => {
  return request(`/patient/order/${id}`, 'DELETE')
}

